Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract async runtimes #1848

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

malivix
Copy link

@malivix malivix commented Mar 31, 2024

Changes

Close #1846 (EDITed by @fzyzcjy to use "Close" to make github auto trigger correlation)

Checklist

  • An issue to be fixed by this PR is listed above.
  • New tests are added to ensure new features are working. Please refer to this page to see how to add a test.
  • ./frb_internal precommit --mode slow (or fast) is run (it internal runs code generator, does auto formatting, etc).
  • If this PR adds/changes features, documentations (in the ./website folder) are updated.
  • CI is passing. Please refer to this page to see how to solve a failed CI.

Remark for PR creator

  • ./frb_internal --help shows utilities for development.
  • If fzyzcjy does not reply for a few days, maybe he just did not see it, so please ping him.

Copy link

welcome bot commented Mar 31, 2024

Hi! Thanks for opening this pull request! 😄

@malivix malivix force-pushed the feat/abstract-async-runtime branch from b7352e9 to 080b6e8 Compare March 31, 2024 14:08
@malivix
Copy link
Author

malivix commented Mar 31, 2024

@fzyzcjy can you check you are happy with approach then I need to fix some stuff about cargo.lock also how user can spawn or spawn_local ...

@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 31, 2024

@malivix Looked at the code very briefly and the rough approach seems OK to me!

Copy link

codecov bot commented Mar 31, 2024

Codecov Report

Attention: Patch coverage is 69.56522% with 14 lines in your changes missing coverage. Please review.

Project coverage is 97.69%. Comparing base (b6300cd) to head (e3a0938).
Report is 6031 commits behind head on master.

Files Patch % Lines
frb_rust/src/rust_async/io/tokio.rs 68.88% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1848      +/-   ##
==========================================
- Coverage   99.27%   97.69%   -1.58%     
==========================================
  Files         359      359              
  Lines       15127    15119       -8     
==========================================
- Hits        15017    14771     -246     
- Misses        110      348     +238     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@malivix malivix marked this pull request as ready for review April 1, 2024 15:13
Copy link
Owner

@fzyzcjy fzyzcjy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Mainly some nits

@@ -362,6 +362,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = FX7V3ATKWH;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Is this your development team? Anyway just run ./frb_internal generate-run-frb-codegen-command-integrate --package frb_example/flutter_via_create (and same command for frb_example/flutter_via_integrate) and it will be fixed

user-utils = ["dep:android_logger", "dep:oslog"]
dart-opaque = ["dep:dart-sys-fork"]
tokio-runtime = ["dep:tokio"]
async-std-runtime = ["dep:async-std"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: seems nuclei is not there

Comment on lines +92 to +93
tokio-runtime = ["dep:tokio"]
async-std-runtime = ["dep:async-std"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we make the names more coherent. e.g. "rust-async, rust-async-tokio, rust-async-async-std, rust-async-nuclei" or something like that

@@ -22,6 +22,7 @@ impl BaseCodec for CstCodec {
// frb-coverage:ignore-end
}

#[allow(dead_code)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: curious why is this dead code?

Comment on lines -5 to -11
#[cfg(not(wasm))]
pub use io::*;

#[cfg(wasm)]
mod web;
#[cfg(wasm)]
pub use web::*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is it really ok to remove these exports 👀

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: seems missing nuclei.rs

}

#[derive(Debug, Clone, Copy, Default)]
pub struct SimpleAsyncRuntime;

impl BaseAsyncRuntime for SimpleAsyncRuntime {
type JoinHandle<O> = wasm_bindgen_futures::JsFuture;

#[cfg(feature = "rust-async")]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: seems no need for this cfg, since the whole web.rs is under that flag

Comment on lines -35 to -42
/// Similar to tokio's `spawn_blocking`, except that you need to provide a second argumnet.
/// If you are using flutter_rust_bridge, the second argument can be easily provided:
/// Just use `FLUTTER_RUST_BRIDGE_HANDLER.thread_pool()`.
///
/// More formally, the second argument is defined as:
///
/// * When on web: The thread pool you want to use.
/// * When on non-web: Unused, can be anything (since we use Tokio's built-in pool).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these docs seems to be missing

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to add tests to ensure everything works.

The most thorough test will need to re-run frb_example/pure_dart multiple times, each using one async runtime. However, that may be super slow.

(I will think about it a bit later)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe we can update doc a bit to tell future users about the new feature :)

@malivix
Copy link
Author

malivix commented Apr 3, 2024

Good job! Mainly some nits

I am on travel will finalize it soon

@fzyzcjy
Copy link
Owner

fzyzcjy commented Apr 3, 2024

I am on travel will finalize it soon

No worries, take your time and have a good vacation!

@debanjanbasu
Copy link
Contributor

@malivix - Is this going to get some love? 🥰, have been waiting for it for some time... Is there anything I can be of help with?

@malivix
Copy link
Author

malivix commented May 26, 2024

@malivix - Is this going to get some love? 🥰, have been waiting for it for some time... Is there anything I can be of help with?

Sorry I was in travel and a bit busy will try to finalize it this week

@anidotnet
Copy link

Any update on this PR please? @malivix sorry to follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for nuclei
4 participants